package com.wc.dao.impl;

import com.wc.dao.DeptDao;
import com.wc.dao.EmpDao;
import com.wc.domain.Dept;
import com.wc.domain.Emp;
import com.wc.fake.DB;

/**
 * @author wanghao
 */
public class DeptDaoImpl implements DeptDao {
    private EmpDao empDao ;
    @Override
    public Dept selectDeptByDeptno(Integer deptno) {
        for (Dept dept : DB.depts) {
            if(dept.getDeptno().equals(deptno)){
                return dept;
            }
        }
        return null;
    }

    @Override
    public Emp selectEmpByEmpno(Integer empno) {
        if (empno == null) {
            return null;
        }
        for (Emp emp : DB.emps) {
            if (emp.getEmpno().equals(empno)) {
                return emp;
            }
        }
        return null;
    }

    @Override
    public boolean updateEmp(Emp emp) {
        return empDao.updateEmp(emp);
    }
}